package com.example.qrcode.vo;

import lombok.Data;

@Data
public class ResultVo<T> {
    private int code;
    private String msg;
    private T data;

    public static <T> ResultVo<T> success(T data) {
        ResultVo<T> result = new ResultVo<>();
        result.code = 0;
        result.msg = "success";
        result.data = data;
        return result;
    }

    public static <T> ResultVo<T> error(String msg) {
        ResultVo<T> result = new ResultVo<>();
        result.code = 1;
        result.msg = msg;
        return result;
    }

    // getter和setter方法
    public int getCode() { return code; }
    public void setCode(int code) { this.code = code; }
    public String getMsg() { return msg; }
    public void setMsg(String msg) { this.msg = msg; }
    public T getData() { return data; }
    public void setData(T data) { this.data = data; }
}